<template>
  <div class="comment-box">
    <div class="com-item" v-for="(item,index) in commentList" :key="index">
      <div class="content">
        {{item.content}}
      </div>
      <div class="time">
        {{utils.day(item.create_time)}}
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { getCurrentInstance, onMounted, ref } from "vue";
import { useStore } from "@/stores/counter";
import utils from "@/utils/utils";

const { userInfos } = useStore();
const commentList = ref<any>([]);
const { proxy }: any = getCurrentInstance();

onMounted(async () => {
  await proxy.$http
    .get("/user/findOne?id=" + userInfos.id)
    .then((res: any) => {
      commentList.value = res.disucss;
    })
    .catch((error: any) => {
      return;
    });
});
</script>

<style scoped lang="less">
.comment-box{
  font-size: 12px;
  .com-item{
    display: flex;
    padding: 10px;
    flex-direction: column;
    background-color: #fff;
    border-radius: 10px;
    margin-bottom: 8px;
    .content{
      margin-bottom: 8px;
    }
  }
}
</style>
